package com.sikaryofficial.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sikaryofficial.backend.domain.dto.req.prize.PrizeOwnerListReq;
import com.sikaryofficial.backend.domain.dto.req.prize.PrizeRedeemListReq;
import com.sikaryofficial.backend.domain.dto.resp.prize.PrizeRedeemDTO;
import com.sikaryofficial.backend.domain.entity.PrizeRedeem;
import com.sikaryofficial.backend.domain.vo.export.PrizeWinnerExportVO;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 奖品兑换Mapper接口
 *
 * @author qinjinyuan
 * @date 2024-07-15
 */
public interface PrizeRedeemMapper extends BaseMapper<PrizeRedeem> {
    /**
     * 奖品兑换记录
     *
     * @param prizeIds     礼品ID
     * @param businessType 业务类型
     * @return 统计集合
     */
    List<PrizeRedeem> prizeRedeemCount(@Param("prizeIds") List<Long> prizeIds, @Param("businessType") Integer businessType);

    IPage<PrizeRedeemDTO> prizeRedeemPageList(Page<PrizeRedeemDTO> customerPage, @Param("req") PrizeRedeemListReq req);

    int countActivityResult(@Param("userId") Long userId);

    int countPrizeRedeem(@Param("userId") Long userId);
    IPage<PrizeRedeemDTO> ownerRedeemList(Page<PrizeRedeemDTO> customerPage, @Param("req") PrizeOwnerListReq req);

    PrizeRedeemDTO getOwnerRedeemDetail(@Param("prizeRedeemId") Long prizeRedeemId);

    PrizeRedeemDTO getOwnerRedeemDetailByResultId(@Param("activityResultId") Long activityResultId);


	int countByUserIdAndTimeRange(@Param("userId") Long userId,
	                              @Param("startTime") LocalDateTime startTime,
	                              @Param("endTime") LocalDateTime endTime);
	int countByUserIdAndPrizeIdAndTimeRange(@Param("userId") Long userId, @Param("prizeId") Long prizeId,
	                                        @Param("startTime") LocalDateTime startTime,
	                                        @Param("endTime") LocalDateTime endTime);

	List<PrizeWinnerExportVO> prizeWinnerExport(@Param("prizeId") Long prizeId);
}
